# Maintainer: Nicolas Frattaroli <ovdev@fratti.ch>

_realname=pngcrush
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.8.13
pkgrel=1
pkgdesc="A tool for optimizing the compression of PNG files (mingw-w64)"
arch=('any')
url="https://pmt.sourceforge.io/pngcrush"
license=('custom')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs" "${MINGW_PACKAGE_PREFIX}-libpng" "${MINGW_PACKAGE_PREFIX}-zlib")
source=("https://downloads.sourceforge.net/pmt/${_realname}-${pkgver}-nolib.tar.gz"
        LICENSE)
sha256sums=('fed0aaf5c098aa8c7f78c75365cd18d7341417326ecbdba547876b7b4f3df4be'
            '5628338f1b1c711b2b2e82d14124bc3001b37216a66f00b18d0b3b9c7e016720')

prepare() {
  mv "${srcdir}/${_realname}-${pkgver}-nolib" "${srcdir}/${_realname}-build-${MINGW_CHOST}"
}

build() {
  cd "${srcdir}/${_realname}-build-${MINGW_CHOST}"
  CFLAGS+=" -DPNGCRUSH_COUNT_COLORS" make
}

package() {
  install -Dm755 ${srcdir}/${_realname}-build-${MINGW_CHOST}/${_realname} \
    "${pkgdir}"${MINGW_PREFIX}/bin/${_realname}
  install -Dm644 LICENSE \
    "$pkgdir"${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}
